package cj.web.admin.controllers;

import java.util.List;

import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.annotation.rest.Post;
import net.paoding.rose.web.var.Model;
import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import cj.utils.DateUtils;
import cj.web.admin.dao.SurveyDAO;
import cj.web.admin.dao.SurveyPeopleDAO;
import cj.web.admin.domain.Survey;
import cj.web.admin.domain.SurveyPeople;
import cj.web.constants.MemuEnum;
import cj.web.login.controllers.BaseController;

@Path("/surveyPeople")
public class SurveyPeopleController extends BaseController{

	private static Logger logger = Logger.getLogger(SurveyPeopleController.class.getName());
	
	@Autowired
	private SurveyDAO surveyDao;
	@Autowired
	private SurveyPeopleDAO SurveyPeopleDao;
	
	@Get("show")
	public String show(Model model,SurveyPeople surveyPeople) {
	
		List<Survey> surveylis = surveyDao.queryAll();
		//MemuEnum
        model.add("MemuEnum",MemuEnum.lkgksryxx);
        model.add("surveylis",surveylis);
		return "/views/survey/surveyPeopleList.vm";
	}

	@Post("getList")
	public String queryList(SurveyPeople surveyPeople) {
		JSONObject jo = new JSONObject();
		List<SurveyPeople> arr = SurveyPeopleDao.query(surveyPeople);
		for(SurveyPeople obj:arr){
			obj.setCreateAt(DateUtils.getMinusTime(obj.getCreateAt(), DateUtils.DATE_FULL_STR, 0));
		}
		jo.put("data", arr);
		jo.put("draw", surveyPeople.getDraw());
		return "@" + jo.toString();
	}
}